package com.etoak.controller;


import com.etoak.common.core.vo.PageVO;
import com.etoak.common.core.vo.ResultVO;
import com.etoak.entity.Order;
import com.etoak.entity.dto.OrderDTO;
import com.etoak.entity.vo.OrderVO;
import com.etoak.request.OrderRequest;
import com.etoak.service.OrderService;
import jakarta.validation.Valid;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author et2406
 * @since 2024-11-22
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    /*
    * 创建订单 post /order
    * */
    @PostMapping
    public ResultVO<Object> create(@Validated @RequestBody OrderDTO order){
        orderService.create(order);

        return ResultVO.success();
    }



    @GetMapping("/list")
    public ResultVO<PageVO<OrderVO>> getList(
            @RequestParam(required = false,defaultValue = "1") int pageNum,
            @RequestParam(required = false,defaultValue = "10") int pageSize,
            Order order
    ) {
        PageVO<OrderVO> orderList = orderService.getOrderList(pageNum, pageSize, order);
        return ResultVO.success(orderList);
    }
    /**
     * 订单创建
     */
    @PostMapping("/prepareOrder")
    public ResultVO<Object> prepareOrder(
            @RequestBody OrderRequest orderRequest
    ){
        orderService.addOrder(orderRequest);

        return ResultVO.success("订单创建成功");
    }

    /**
     * 订单删除
     */
    @DeleteMapping("{orderId}")
    public ResultVO<Object> deleteOrderById(
            @PathVariable String orderNo
    ){
        orderService.deleteOrderById(orderNo);
        return ResultVO.success("删除成功");
    }


    public void get(){

    }

    public void get2(){

    }

    public void get1(){

    }











    public void get4(){

    }

    public void get3(){

    }

    public void getNextMain(){

    }

    public void getMain(){

    }


    public void getMinor2(){

    }


    public void getMinor(){

    }

    public void getMinor4(){

    }

    public void getMinor3(){

    }
}

